/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testing;

    
import org.mockito.ArgumentMatcher;
import org.mockito.Mockito;
import java.util.List;

public class MockitoDemo5 {

    public static void main(String[] args) {
        // arrange
        List<String> listMock = Mockito.mock(List.class);
        Mockito.when(listMock.get(Mockito.anyInt())).thenReturn("odd");
        Mockito.when(listMock.get(evenInt())).thenReturn("even");
        // act
        System.out.println(listMock.get(0));
        System.out.println(listMock.get(1));
    }

    private static int evenInt() {
        return Mockito.intThat(new ArgumentMatcher<Integer>() {
            @Override
            public boolean matches(Object arg) {
                return ((Integer) arg) % 2 == 0;
            }
        });
    }
}
